package com.dragon.pear.modules.trade.service.assistants.converters;

import java.sql.Timestamp;
import com.dragon.common.base.utils.ConvertUtil;
import com.dragon.common.base.utils.DbUtil;
import com.dragon.common.spring.annotations.DataConverter;
import com.dragon.common.spring.business.base.BaseConverter;
import com.dragon.utils.TimeUtil;
import com.dragon.pear.modules.trade.domain.entity.TradeGoodsAttrEntity;
import com.dragon.pear.modules.trade.web.model.params.create.TradeGoodsAttrCreateParam;
import com.dragon.pear.modules.trade.web.model.params.update.TradeGoodsAttrUpdateParam;
import com.dragon.pear.modules.trade.web.model.results.TradeGoodsAttrResult;

/**
 * @author Chris Chan
 * Create on 2025-09-30 22:06
 * Use for: 商品属性关联 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class TradeGoodsAttrConverter implements BaseConverter<
        TradeGoodsAttrEntity,
        TradeGoodsAttrCreateParam,
        TradeGoodsAttrUpdateParam,
        TradeGoodsAttrResult> {
    @Override
    public TradeGoodsAttrEntity fromParam(TradeGoodsAttrCreateParam param) {
        TradeGoodsAttrEntity entity = new TradeGoodsAttrEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public TradeGoodsAttrEntity fromUpdateParam(TradeGoodsAttrUpdateParam param) {
        TradeGoodsAttrEntity entity = ConvertUtil.convert(param, TradeGoodsAttrEntity.class);
        return entity;
    }

    @Override
    public TradeGoodsAttrResult toResult(TradeGoodsAttrEntity entity) {
        TradeGoodsAttrResult result = ConvertUtil.convert(entity,TradeGoodsAttrResult.class);
        return result;
    }
}